/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef VERBPARSER_H
#define VERBPARSER_H

#include <map>

#include "Parser.h"
#include "Command.h"

namespace Chronos {

class Session;
class VerbAdjective;
class Words;
class StringBuilder;

class VerbParser : public Parser {
public:
    VerbParser(DefaultCommand& defaultCmd_);
    virtual ~VerbParser();
    virtual void parse(Session& session, const char* text);

    enum CommandType {VERB, VERB_ADJ, VERB_OBJ, VERB_ADJ_OBJ, VERB_OBJ_ADJ_OBJ, VERB_OBJ_OBJ};
    void addCommand(const std::string& verb, const std::string& adj, CommandType type, Command* cmd);
    void removeCommand(const std::string& verb, const std::string& adj);

    virtual void showCommands(Session& session) const;
    virtual void printStatus(StringBuilder& buffer) const;
private:
    int containsAdj(const Words& words, const std::string& adj) const;
    bool runVerb(Session& session, const Words& words, VerbAdjective* adj, int adjPos);

    typedef std::map<std::string, VerbAdjective*> Commands;
    typedef Commands::const_iterator CommandsConstIter;
    typedef Commands::iterator CommandsIter;
    Commands commands;

    DefaultCommand* defaultCmd;
    unsigned int cmdCount;

    VerbParser(const VerbParser&);
    VerbParser& operator=(const VerbParser&);
};

}

#endif

